package com.edou.study.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatClientController {

    private final ChatClient dashscopeChatClient;

    public ChatClientController(ChatClient dashscopeChatClient) {
        this.dashscopeChatClient = dashscopeChatClient;
    }

    @GetMapping("/chatclient/dochat")
    public String doChat(@RequestParam(name = "msg", defaultValue = "2加9等于几") String msg) {
        return dashscopeChatClient.prompt().user(msg).call().content();
    }
}
